﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ENProyectoSIETE;
using CADProyectoSIETE.Properties;
using System.Configuration;
using System.Data;
using System.Data.Sql;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using CADProyectoSIETE.BDProyecto7DataSetTableAdapters;
namespace CADProyectoSIETE
{
    public class TabernaCAD
    {
        SqlConnection conexion = new SqlConnection(Settings.Default.BDProyecto7ConnectionString);

        public TabernaCAD() { }

        public DataTable obtenerObjetosTaberna()
        {
            try
            {
                //asdadasd
                DataSet bd = new DataSet();
                DataTable tabla = new DataTable();
                TabernaTableAdapter taTableAdaptar = new TabernaTableAdapter();
                tabla = taTableAdaptar.obtenerObjetosTaberna();
                return tabla; 

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void insertar(int id, int precio) {
            TabernaTableAdapter tabernaTA = new TabernaTableAdapter();
            tabernaTA.Insert(id,precio);
        }

        public void borrar(int id) {
            try
            {
                TabernaTableAdapter tabernaTA = new TabernaTableAdapter();
                tabernaTA.Delete(id);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }

        public DataTable buscarTaberna(string text) 
        {
            try
            {
                TabernaTableAdapter tabernaTA = new TabernaTableAdapter();
                return tabernaTA.obtenerObjetosTabernaNombre(text);
            }
            catch (Exception ex) 
            {
                throw ex;
            }
        }

        public DataSet obtenerObjetosNoTaberna() 
        {
            try 
            {
                //TabernaTableAdapter tabernaTA = new TabernaTableAdapter();
                DataSet bd = new DataSet();

                SqlDataAdapter da = new SqlDataAdapter("SELECT idObjeto, nombreObjeto, descripcionObjeto FROM Objeto WHERE (idObjeto NOT IN(SELECT idObjetoTaberna FROM Taberna))", conexion);da.Fill(bd,"objetos");
                return bd;
                //return tabernaTA.obtenerObjetosNoTaberna();
            }
            catch (Exception ex)
            { throw ex;
            }
        
        }
    }
}
